//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
//表格
import uniForms from "/uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
//语言
import Lang from '@/utils/lang.js';
//公共公益方法
import commonBenefit from '@/common/commonbenefit.js';
//公共方法
import Base from '@/common/base.js';
//表格
import uDataSelect from "/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue";
//微信api
import weChat from '@/lib/wechat.js';
//登录api
import Login from '@/lib/login.js';
//用户
import User from '@/lib/user.js';
//公共底部
import Tabbar from "/pages/headerfoot/pages/benefitfooter.vue";
//cache缓存
import Cache from '@/utils/cache.js';

export default {
	components: {
		myHeader,
		uniForms,
		uDataSelect,
		Tabbar
	},
	data() {
		return {
			informationfilling: Lang.lang.reviewapadd,
			lang: Lang.lang, //语言
			teamclass: [],
			valiFormData: {
				team: '',
			},
			downlist: [],
			school_id:'',
			teacher_team:'',
		}
	},
 
	onShow() {
		var that = this;
		that.ifreglogin();
	},
	methods: {
		//判断是否需要注册或者登录与其他
		async ifreglogin() {
			var that = this;
			//注册
			await Base.globalauthorization();
			//获取用户信息1
			await that.userinfo();
			
		},
		//获取用户信息1
		userinfo() {
			var that = this;
			var data = {};
			commonBenefit.getUserApiMethod(data).then(res => {
				if (res) {
					//获取学校列表
					var datas = {};
					datas['school_id'] = that.school_id=res.school_id;
					 that.teacher_team=res.teacher_team;
					 //班级下拉
					that.getteamlist();
					 
					commonBenefit.getSchoolApiMethod(datas).then(ress => {
						if (ress) {
							that.schoolchange(res.school_id)
							that.school = ress.school_name;
						}
					});
				}
			});
			
		},
		//学校改变
		schoolchange(e) {
			var that = this;
			that.teamclass = [];
			that.valiFormData.team = '';
			//获取班级
			var school_id = e;
			if (school_id) {
				var data = {};
				data['school_id'] = school_id;
				commonBenefit.getTeamListApiMethod(data).then(res => {
					if (res) {
						that.teamclass = res;
					}
				});
			}
		},
		//班级改变1
		teamchangee(e) {
			var that = this;
			that.valiFormData.team = e;
		},
		//班级下拉
		getteamlist() {
			var that = this;
			var data = {};
			data['school_id'] = that.school_id;
			data['teacher_team'] = that.teacher_team;
			commonBenefit.getTeamListApiMethod(data).then(res => {
				if (res) {
					that.downlist = res;
				}
			})
		},
		//删除
		del(e){
			var that = this;
			uni.showModal({
				title: that.lang.tip,
				content: that.lang.ifdel,
				showCancel: true,
				cancelText: that.lang.cancel,
				confirmText: that.lang.ok,
				success: function(res) {
					if (res.confirm) {
						// var data = {};
						// data['teacher_team'] = e;
						// commonBenefit.getTeamListApiMethod(data).then(res => {
						// 	if (res) {
								
						// 	}
						// })
					}
				}
			});
		},
		//提交
		submit() {
			var that = this;
			var data = {};
			data['team_id'] = that.valiFormData.team;
			commonBenefit.setUserTeamApiMethod(data).then(res => {
				if (res) {
					console.log(res);
				}
			});
		},
	}
}